package com.ray.controller;

import static org.hamcrest.CoreMatchers.nullValue;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.ObjectIdGenerators.StringIdGenerator;
import com.ray.bean.CustomerBean;
import com.ray.bean.DatatablesViewPageBean;
import com.ray.bean.DepartmentBean;
import com.ray.bean.FeedOrderDetailBean;
import com.ray.bean.FileManagerBean;
import com.ray.bean.MaterialBean;
import com.ray.bean.OrderInfoTemplateBean;
import com.ray.bean.PersonBean;
import com.ray.exception.ServiceException;
import com.ray.mapper.OrderCreateMapper;
import com.ray.pojo.AttendDevicePojo;
import com.ray.pojo.AttendSourceRecordPojo;
import com.ray.pojo.MyUser;
import com.ray.service.BasicDataService;
import com.ray.service.FileManagerService;
import com.ray.service.OrderCreateService;
import com.ray.service.OrderInfoTemplateService;
import com.ray.service.VisitorService;
import com.ray.util.RequestUtil;
import com.ray.util.ResponseUtil;
import com.ray.util.UploadFilesUtil;
import com.ray.util.picUtil.PicUtils;
import com.ray.util.qiniu.QiniuConfig;
import com.ray.util.qiniu.QiniuUploadUtils;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.sun.org.apache.bcel.internal.generic.NEW;

/**
 * 文件管理
 * 订单创建数据获取及提交
 * @author Shensg
 * 2018年1月24日
 */

@SuppressWarnings("unused")
@RestController
@RequestMapping("/visitor")
public class VisitorController {
	
	@Autowired 
	VisitorService visitorService;
	
	@RequestMapping("/saveVisitorInfo")
	@ResponseBody
	public Map saveVisitorInfo(HttpServletRequest request) throws IOException {
		@SuppressWarnings("unchecked")
		Map<String,String> map = RequestUtil.getRequestAllParamNotLogin(request);
		AttendDevicePojo pojo = visitorService.saveVisitorInfo(map);
		return ResponseUtil.ResponseResult(pojo.getCompany());
	}
	
	@RequestMapping(value="/sendClockMessage",method=RequestMethod.GET)
	@ResponseBody
	public void sendClockMessage(HttpServletRequest request) {
		@SuppressWarnings("unchecked")
		Map<String,Object> map=RequestUtil.getRequestAllParamNotLogin(request);
		visitorService.sendClockMessage(map);
	}
	
	@RequestMapping("/queryAttendance")
	@ResponseBody
	public Map queryAttendance(HttpServletRequest request) throws ServiceException, ParseException {
		Map<String,Object> map=RequestUtil.getRequestParamByGeneric(request);
		return ResponseUtil.ResponseResult(visitorService.queryAttendance(map));
	}
	
	@RequestMapping("/queryVisitorList")
	@ResponseBody
	public Map queryVisitorList(HttpServletRequest request) throws ServiceException, ParseException {
		Map<String,Object> map=RequestUtil.getRequestParamByGeneric(request);
		return ResponseUtil.ResponseResult(visitorService.queryVisitorList(map));
	}
	
	@RequestMapping("/deleteVisitorById")
	@ResponseBody
	public Map deleteVisitorById(HttpServletRequest request) throws ServiceException, ParseException {
		Map<String,Object> map=RequestUtil.getRequestParamByGeneric(request);
		visitorService.deleteVisitorById(map);
		return ResponseUtil.ResponseResult("删除成功");
	}
}
